<style scoped lang="scss">
.container1 {
  font-size: 12px;
  background: #fff;
  padding: 10px;
  border-radius: 5px;
  border: 1px solid #ddd;
}
</style>
<template>
  <div class="container1">
    <div style="position: relative;
    box-sizing: border-box;
    min-height: 22px;
    ">
      <span>{{
          ($props.item?.dtlList || []).map(_item => dateFormatYYYYMMDDHHmmss(_item?.addTime, 'MM-DD HH:mm')).join(';')
        }}</span>


      <label style="position: absolute;top: 0px;right: 0px;">
        <van-tag size="mini"
                 v-if="$props.item?.receivingType"
                 type="primary"
        >
          <span v-if="$props.item?.receivingType==1">物料</span>
          <span v-if="$props.item?.receivingType==2">工艺</span>
        </van-tag>
        <template v-if="$props.item?.payState">
          <dic-tag code="material_receiving_paystate" size="mini"
                   style="margin-left: 4px;margin-bottom: 2px;"
                   :value="$props.item?.payState"></dic-tag>
        </template>
      </label>


    </div>
    <div style="margin-bottom: 5px;">
      <span>{{
          lodashuniqBy(($props.item?.dtlList || []).map(_item => _item?.develMaterial?.develNo)).join(';')
        }}</span>
    </div>
    <div style="display: flex;justify-content: space-between;margin-top: 3px;margin-bottom: 5px;">
      <label>
        <span><span v-if="$props.item?.receivingType==1">物料</span><span
            v-if="$props.item?.receivingType==2">工艺</span>总费用:</span>
        <span>{{ toFixedInt($props.item?.receivingMoney) }}</span>
      </label>
      <label for="">
        <span>专送总费用:</span>
        <span>{{ toFixedInt($props.item?.courierMoney) }}</span>
      </label>
    </div>

      <div style="padding-bottom: 5px;">
        <span>可请款:</span>
        <span>{{ toFixedInt(($props.item?.dtlList||[]).reduce((total,a)=>{
            if(a?.payState<=1&&a?.expenseType==5){
              if($props.item?.receivingType==1){
                total+=(parseFloat(a?.materialCheck?.materialMoney||0))+(parseFloat(a?.materialCheck?.courierMoney||0))
              }else if($props.item?.receivingType==2){
                total+=parseFloat(a?.materialSecondary?.processMoney||0)
              }
            }
            return total;
        },0)) }}</span>
      </div>
    <div style="padding-bottom: 5px;">
        <span>请款中:</span>
        <span>{{ toFixedInt(($props.item?.dtlList||[]).reduce((total,a)=>{
                 if(a?.payState==3){
                   total+=parseFloat(a?.applyMoney||0)
                 }
                 return total;
             },0)) }}
        </span>
    </div>
      <div style="padding-bottom: 5px;" v-if="$props.item?.payState>=1">
        <span>已请款:</span>
        <span>{{ toFixedInt(($props.item?.dtlList||[]).reduce((total,a)=>{
          if(a?.payState==10){
            total+=parseFloat(a?.applyMoney||0)
          }
          return total;
        },0)) }}
        </span>
      </div>

    <div style="margin-top: 5px;padding-top: 5px;border-top: 1px solid #ddd;">
      <span style="padding-right: 30px;" v-if="$props.item?.receivingUser">{{ $props.item?.receivingUser }}</span>
      <span v-if="$props.item?.brandName">{{ $props.item?.brandName }}</span>
    </div>


  </div>
</template>
<script>
import { dateFormatMMDD, dateFormatYYYYMMDDHHmmss } from '@/utils/dateUtils';
import { toFixedInt } from '@/utils';
import { lodashuniqBy } from '../../../utils/lodashUtil';
import DicTag from '@/components/DicTag/dic-tag.vue';

export default {
  components: { DicTag },
  methods: {
    lodashuniqBy,
    toFixedInt,
    dateFormatYYYYMMDDHHmmss, dateFormatMMDD,
  },
  data() {
    return {};
  },
  props: {
    item: {
      type: [Object],
    },
  },
};
</script>
